<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./jq-3.6.0.js"></script>
</head>

<body>
    <div>
        姓名:<input id="name" /><br/>
        <input type="submit" onclick="query()" value="查询">
    </div>
    <div id="content">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
</body>
<script>
    const query = () => {
        let username = $("#name").val();
        $.get('http://localhost:8082/student/queryByName', {
            name1: username
        }, res => {
            const items = $('#content').children();
            if (res.length === 0) {
                $(items[0]).html(`姓名:未查到`);
                $(items[1]).html(`年龄:未查到`);
                $(items[2]).html(`身高:未查到`);
                $(items[3]).html(`体重:未查到`);
            } else {
                $(items[0]).html(`姓名:${res[0].name}`);
                $(items[1]).html(`年龄:${res[0].age}`);
                $(items[2]).html(`身高:${res[0].height}`);
                $(items[3]).html(`体重:${res[0].weight}`);
            }
        })
    }
</script>


</html>